import { composeMiddleware, Middleware } from '../deps.ts'
import preRouters from './pre/index.ts'
import primaryRouters from './primary/index.ts'

export default () => {
  const middleware: Middleware[] = []
  const routers = [...preRouters, ...primaryRouters]
  routers.forEach((router) => {
    middleware.push(router.routes())
    if (router.allowedMethods) {
      middleware.push(router.allowedMethods())
    }
  })
  return composeMiddleware(middleware)
}